package Items;

import java.util.ArrayList;

import virtualTabletop.Die;

/**
 * For making weapons
 * 
 * @author ama063, bjo013
 * 
 */
public class Weapon extends Item
{

	private Weapons name;
	private int nbDice;
	private Die dmgDice;
	private WeaponType type;
	private int range;
	private int profBonus;
	private WeaponGroup group;
	private ArrayList<WeaponProperty> weaponPropterties;

	/**
	 * Constructor for weapons
	 * 
	 * @param name
	 *            name of the weapon
	 * @param profBonus
	 *            proficiency bonus of the weapon
	 * @param nbDice
	 *            number of dice
	 * @param dmgDice
	 *            which dice
	 * @param type
	 *            type of weapon
	 * @param range
	 *            range of the weapon, 1 is a melee weapon
	 * @param group
	 *            weapon group
	 * @param weaponProperties
	 *            Properties of the weapon
	 */
	public Weapon(Weapons name, int profBonus, int nbDice, Die dmgDice,
			WeaponType type, int range, WeaponGroup group,
			ArrayList<WeaponProperty> weaponProperties)
	{
		this.name = name;
		this.nbDice = nbDice;
		this.dmgDice = dmgDice;
		this.type = type;
		this.range = range;
		this.group = group;
		this.profBonus = profBonus;
		this.weaponPropterties = weaponProperties;
	}

	/**
	 * get the number of dice
	 * 
	 * @return number of dice
	 */
	public int getNbDice()
	{
		return nbDice;
	}

	/**
	 * get the die
	 * 
	 * @return with what die to roll with
	 */
	public Die getDie()
	{
		return dmgDice;
	}

	/**
	 * returns weapontype
	 * 
	 * @return type of weapon
	 */
	public WeaponType getType()
	{
		return type;
	}

	/**
	 * how far the weapon shoots in squares
	 * 
	 * @return range of the weapon in squares
	 */
	public int getRange()
	{
		return range;
	}

	/**
	 * Calculates the max range of the weapon
	 * 
	 * @return max range
	 */
	public int getMaxRange()
	{
		return type == WeaponType.Melee ? range : range * 2;
	}

	@Override
	public String toString()
	{
		String s = new String();
		s += name + "\n";
		s += "Weapon type: " + type + " +" + profBonus + "\n";
		s += "Weapon group: " + group + "\n";
		s += "Dmg: " + nbDice + dmgDice;
		if (type == WeaponType.Ranged || type == WeaponType.Thrown)
		{
			s += "\nRange: " + range;
		}
		if (!weaponPropterties.isEmpty())
		{
			s += "Weapon properties:\n";
			for (WeaponProperty p : weaponPropterties)
			{
				s += p + " ";
			}
		}
		return s;
	}
}
